package com.study.springboot.SpringBoot_A.dao;

import com.study.springboot.SpringBoot_A.bean.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author 赵超
 * @Description
 * @create 2018-03-21 10:16
 **/
public interface UserRepository extends JpaRepository<User, Long> {

    User findByUserName(String userName);

    User findByUserNameOrEmail(String username, String email);

    @Query(value = "select count(*) from User bean")
    Long getCountOfUser();

    Page<User> findByUserName(String userName, Pageable pageable);

    @Query(value = "select u from User u where u.nickName = ?1 or u.userName = ?2")
    List<User> findByNickNameOrUserName(String nickName, String userName);
}
